import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image} from '@tarojs/components'
import './foodItem.scss'

export default class FoodItem extends Component {

  constructor (props) {
    super(props)
    this.state = {
    }
  }
  componentWillMount () { }

  componentDidMount () {

  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }
  test (test) {
    this.props.onCw(test)
  }
  render () {
    const { food } = this.props
    const originalPrice = Number(food.originalPrice).toFixed(2)
    const discountPrice = Number(food.discountPrice).toFixed(2)
    return (
      <View className='food-item'>
        <View className='food-img'>
          <Image onClick={this.test.bind(this, 3333)} className='taro-img' mode='scaleToFill' src={food.foodImg}  />
        </View>
        <View className='food-title'>{food.foodTitle}</View>
        <View className='food-price'>
          <Text className='discount-price'>{discountPrice}</Text>
          <Text className='original-price'>{originalPrice}</Text>
        </View>
      </View>
    )
  }
}

FoodItem.defaultProps = {
  food: {}
}
